package net.hn.hnms.biz.plan.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.plan.request.DimDrivageFaceReq;
import net.hn.hnms.biz.plan.service.IDimDrivageFaceService;
import net.hn.hnms.biz.plan.vo.DimDrivageFaceVO;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 掘进工作面
 *
 * @author zhaoyang
 * @date 2022-08-01
 */

@Api(value = "掘进工作面模块", tags = {"掘进工作面"})
@RestController
@RequestMapping("/drivage/face")
public class DimDrivageFaceController extends BaseController {


    @Autowired
    private IDimDrivageFaceService dimDrivageFaceService;


    /**
     * 新增掘进工作面
     */
    @ApiOperation("新增掘进工作面")
    @SaCheckPermission("drivage:face:add")
    @PostMapping("/add")
    @Log(title = "新增掘进工作面", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody DimDrivageFaceReq dimDrivageFace) {
        return toAjax(dimDrivageFaceService.insert(dimDrivageFace));
    }

    /**
     * 删除掘进工作面
     */
    @ApiOperation("删除掘进工作面")
    @SaCheckPermission("drivage:face:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除掘进工作面", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        dimDrivageFaceService.deleteBatch(idList);
        return R.ok();
    }

    /**
     * 修改掘进工作面
     */
    @ApiOperation("修改掘进工作面")
    @SaCheckPermission("drivage:face:update")
    @PutMapping("/update")
    @Log(title = "修改掘进工作面", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody DimDrivageFaceReq dimDrivageFace) {
        dimDrivageFaceService.updateById(dimDrivageFace);
        return R.ok();
    }

    /**
     * 获取掘进工作面列表
     */
    @ApiOperation("获取掘进工作面分页列表")
//    @SaCheckPermission("drivage:face:page")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<DimDrivageFaceVO>> page(DimDrivageFaceReq dimDrivageFace, PageQuery pageQuery) {
        return R.ok(dimDrivageFaceService.selectPageList(dimDrivageFace, pageQuery));
    }

    /**
     * 启用/禁用
     */
    @ApiOperation("启用/禁用")
    @SaCheckPermission("drivage:face:status:change")
    @PutMapping("/status/change/{id}/{status}")
    @Log(title = "掘进工作面启用/禁用", businessType = BusinessType.GRANT)
    public R<Void> changeStatus(@PathVariable("id") String id, @PathVariable("status") Integer status) {
        dimDrivageFaceService.changeStatus(id, status);
        return R.ok();
    }

    /**
     * 获取掘进工作面列表
     */
    @ApiOperation("获取掘进工作面列表")
//    @SaCheckPermission("drivage:face:list")
    @GetMapping("/list")
    @AutoSetMineCode
    public R<List<DimDrivageFaceVO>> list(DimDrivageFaceReq dimDrivageFace) {
        return R.ok(dimDrivageFaceService.selectList(dimDrivageFace));
    }

    /**
     * 获取掘进工作面详情
     */
    @ApiOperation("获取掘进工作面详情")
//    @SaCheckPermission("drivage:face:detail")
    @GetMapping("/{id}")
    public R<DimDrivageFaceVO> detail(@PathVariable("id") String id) {
        return R.ok(dimDrivageFaceService.selectDetailById(id));
    }


}
